package com.tuanzi.loan.web.bean.family;

import com.tuanzi.loan.business.service.family.CommSysCodeService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.view.family.SpaceConfInfoView;
import com.tuanzi.loan.web.configuration.JSFInfoBean;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;

/**
 * @author Ray 2017/09/21
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class SpaceConfInfoBean extends JSFInfoBean<SpaceConfInfoView> {
	
    private static final long serialVersionUID = -2152778554108785342L;
    @Autowired
    private CommSysCodeService commSysCodeService;
    
    @PostConstruct
    private void init() {
        String id = getParamFromRequest("id");
        if (StringUtils.isNotBlank(id)) {
            $ = commSysCodeService.loadSpaceConfInfoView(NumberUtils.toLong(id));
        } else {
            $ = new SpaceConfInfoView();
            changeStatusToAdd();
        }
    }
    
    public void onSave() {
    	commSysCodeService.saveOrUpdateSpaceConfInfoView($);
        changeStatusToView();
        addSuccessfullyMessage();
    }
    

}

















